<?php


class Controller
{
    
    public function __construct()
    {
        $this->view = new View(); 
    }
    
    /**
    *  Get model
    */
    public function loadModel($name)
    {
        $path = 'models/' . $name . '_model.php';
        
        if(file_exists($path))
        {
            require $path;
            $modelName = $name . '_Model';
            
            $this->model = new $modelName();
        }   
    }
    
    /**
    * check admin 
    * 
    */
    protected function checkLoggin()
    {   
        Session::init();
        $loggin = Session::get('log_in');
        $role = Session::get('role');
        
        // var_dump($role); die;
        if($loggin !== true || $role !== 'admin')
        {
            // todo error massage  may be check is session start
            header('location: ../login');
            exit;
        }
    }
    
    
    
    /**
    * remove all tag in data
    * 
    * @param mixed $data
    */
    public function strip_tag($data)
    {
        
    }
    
    
}